package com.tsf.demo.inventory.controller;

import com.tsf.demo.commons.vo.Product;
import com.tsf.demo.inventory.proxy.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class InventoryController {

	@Autowired
	private ProductService productService;

	//查询库存
	@RequestMapping(value = "/product/{id}", method = RequestMethod.GET)
	public Product getProduct(@PathVariable String id) {
		return productService.getProduct(id);
	}
	//查询库存
	@RequestMapping(value = "/inventory/{id}", method = RequestMethod.GET)
	public Product getProduct2(@PathVariable String id) {
		return productService.getProduct(id);
	}

	//入库
	@RequestMapping(value = "/inventory/inbound", method = RequestMethod.GET)
	public String inbound(@RequestParam(value="productId", required=true) String productId,
						   @RequestParam(value="quantity", required=true) Integer quantity) {
		return productService.inbound(productId,quantity);
	}

	//出库
	@RequestMapping(value = "/inventory/outbound", method = RequestMethod.GET)
	public String outbound(@RequestParam(value="productId", required=true) String productId,
						  @RequestParam(value="quantity", required=true) Integer quantity) {
		return productService.outbound(productId,quantity);
	}

}